package com.study.studyfive.quartz.demo;

import org.quartz.*;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author zhangwei
 * @version 1.0
 * @date 2023/9/24 17:44
 */
public class SecondJob implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //打印当前的执行时间
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("现在的时间是："+ sf.format(date));

        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        String name= jobDataMap.getString("name");
        //具体的业务逻辑
        System.out.println(  name +"开始生成任务报表 或 开始发送邮件");
    }
}
